#ifndef QOgreWidgetDemo_h__
#define QOgreWidgetDemo_h__

#include <OGRE/Ogre.h>

#include <Terrain/OgreTerrain.h>
#include <Terrain/OgreTerrainGroup.h>

#include <QMainWindow>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>
#include <SdkTrays.h>

#include <QtSerialPort/QSerialPort>
#include <QLabel>
#include <QSpinBox>


#include "Ogre3D/IOgreEventHandler.h"
#include "Ogre3D/QCameraMan.h"
#include "Ogre3D/MyObject.h"
#include "Bullet/physics.h"



namespace Ui {
class MainWindow;
}


class QOgreWidget;
class Console;
class SettingsDialog;
class QOgreWidgetDemo : public QMainWindow, public IOgreEventHandler {
    Q_OBJECT

public: // interface
    QOgreWidgetDemo();
    ~QOgreWidgetDemo();


	void createQtWidgets();
	
private:
	
    Ui::MainWindow *ui;

    QOgreWidget *mOgreWidget;
	

    int mMouseMoveXOld;
    int mMouseMoveYOld;

	
	bool isCameraManReady;
    

private slots:
    
    // implements IQOgreEventHandler
    virtual void ogrePaintEvent(QPaintEvent *pEvent) {}
    virtual void ogreResizeEvent(QResizeEvent *rEvent) {}
    virtual void ogreUpdate() {}
    virtual void ogreMousePressEvent(QMouseEvent *event);
    virtual void ogreMouseMoveEvent(QMouseEvent *event);
	virtual void ogreKeyPressEvent(QKeyEvent *event);
	virtual void ogreKeyReleaseEvent(QKeyEvent *event);
	
	
private slots:
    void openSerialPort();
    void closeSerialPort();
    void about();

    void writeData(const QByteArray &data);
	void setController(bool);

    //! [7]
    void readData();
    void handleError(QSerialPort::SerialPortError error);

    void setBoundaryVisible(bool );

	
private:
    void initActionsConnections();

	
    Console *console;
    SettingsDialog *settings;
    QSerialPort *serial;
    QByteArray buffer;
};


#endif // QtOgreApplication_h__
